//
//  PopViewController.swift
//  iiatn
//
//  Created by mnine on 18/4/15.
//  Copyright © 2018年 mnine. All rights reserved.
//

import UIKit
import SVProgressHUD

class PopViewController: UITableViewController{

    var dataArray = ["分享到","联系我们"]
    var pro : WPro?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID")
        preferredContentSize = CGSize(width: 130, height: 70)
        tableView.rowHeight = 35
    }
    
    //MARK: - Delegate
    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataArray.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath)
        
        cell.textLabel?.text = dataArray[indexPath.row]
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        if indexPath[1] == 1 {
            UIPasteboard.general.string = "01067171008"
            var msg = "项目地点：\((pro?.filterattr_value!.components(separatedBy: "|")[0])!)\n"
            msg += "项目名称：\((pro?.title)!)\n"
            msg += "服务热线：010－67171008"
            let alertController = UIAlertController(title: "联系我们",
                                                    message: msg, preferredStyle: .alert)
            let okAction = UIAlertAction(title: "确认", style: .cancel, handler: nil)
            alertController.addAction(okAction)
            self.present(alertController, animated: true, completion: nil)
            SVProgressHUD.showInfo(withStatus: "服务热线 01067171008 已复制到粘贴板")
        }else {
            WActionSheet.show(pro: pro!)
        }
        
    }

}
